package org.onion.pattern.notify.dingtalk.msg;

import lombok.Data;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

/**
 * 钉钉机器人消息
 */
@Data
@Accessors(chain = true)
public class DingTalkRobotFeedCardMsg {

    private List<Links> links;

    public DingTalkRobotFeedCardMsg() {
        this.links = new ArrayList<>();
    }

    public DingTalkRobotFeedCardMsg append(String title) {
        this.links.add(new Links().setTitle(title));
        return this;
    }

    public DingTalkRobotFeedCardMsg append(String title, String messageURL) {
        this.links.add(new Links().setTitle(title).setMessageURL(messageURL));
        return this;
    }

    public DingTalkRobotFeedCardMsg append(String title, String messageURL, String picURL) {
        this.links.add(new Links().setTitle(title).setMessageURL(messageURL).setPicURL(picURL));
        return this;
    }

    @Data
    @Accessors(chain = true)
    public static class Links {

        private String messageURL;

        private String picURL;

        private String title;
    }

}
